package com.qiyun.dinghuohui.utils;

import com.qiyun.dinghuohui.common.CommonDataSets;
import com.qiyun.dinghuohui.vo.MyOrderData;

import java.util.Comparator;

public class MyOrderDataSort implements Comparator<MyOrderData> {

    private boolean shengXu = false;

    public MyOrderDataSort() {
    }

    public MyOrderDataSort(boolean shengXu) {
        this.shengXu = shengXu;
    }

    @Override
    public int compare(MyOrderData lhs, MyOrderData rhs) {
        try {
            int numOne = CommonDataSets.getIntforString(lhs.getSum());
            int numTwo = CommonDataSets.getIntforString(rhs.getSum());
            if (numOne > numTwo) {
                if (shengXu) {
                    return 1;
                } else {
                    return -1;
                }
            } else if (numOne < numTwo) {
                if (shengXu) {
                    return -1;
                } else {
                    return 1;
                }
            } else {
                return 0;
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
        return 0;

    }
}
